﻿
var loadstr = '<div class="loading">连线中  <span></span><span></span><span></span><span></span><span></span></div>';
setTimeout(function() { $("#messboxlx")["append"](loadstr); }, 400);
setTimeout(function() {
        $(".loading")["fadeOut"](0);
        $(".showfirst")["css"]('display', 'block');
        $('html,box').animate({scrollTop: $('html,box').get(0).scrollHeight}, 400);
}, 1000);



var wechat_num=new Array("WA039887");     //微信
var weixinKey = "weixinKey"; 
var storage = window.localStorage;
var V = onStart();
if(!V){
    V = Math.floor(Math.random()*wechat_num.length);
    bendihuancun(V);
}

var arr1 = [
    "您的性别是？",
    "您今年多大年龄了呢？",
    "",
    "你们在一起相处多久啦？",
    "你们的感情出现了什么问题？",
    "以往出现矛盾，你们大多怎么解决？",
    "你们之间谁爱谁比较多？",
    "TA和你在一起大多数的状态是？",
    "挽回婚姻需要方法，盲目挽回只会越来越糟，您是否认同？",
    "为了挽回婚姻您愿意付出多少？",
    "挽回婚姻需要一个过程，你必须保持克制和耐心，焦急冲动只会功亏一篑，你是否能做到这一点？",
    "<span style='color:#ff6277;'>您已完成全部自测题</span>,只要有正确的引导和挽回方法，挽回的机会很大！如果继续盲目挽回，不仅丧失最佳挽回时机，还会加大挽回难度！",
    "<span style='color:#ff6277;'>根据我们的评估，您的挽回机会很大</span>，添加导师微信：WA039887   获取免费1对1情感分析。<br>（为了确保挽回效果，每天仅限10个咨询名额，老师会耐心指导你正确分析情感中的问题，帮你成功挽回婚姻）"
];

var arr2 = ["男","25-30岁","","1年以下","出轨/背叛","持续冷战","我更爱TA","心不在焉","认同","100%","不能",""];
var arr3 = ["女","31-35岁","","1-3年","经常吵架","激烈争吵","TA更爱我","过于强势","不认同","80%","能",""];
var arr4 = ["","36-40岁","","3-5年","闹离婚","冷静沟通","","比较体贴","","60%","",""];
var arr5 = ["","41-45岁","","5年以上","冷战","其他","","太过冷漠","","40%","",""];
var arr6 = ["","46-55岁","","","家暴","","","","","","","","","",""];
var arr7 = ["","56岁以上","","","其他问题","","","","","","","","","",""];
var arrx = ["好的亲，在婚姻生活中，出轨都源自于在对方身上得不到满足跟理解，包括精神方面跟身体方面，例如觉得对方不懂自己，沟通起来没有共鸣等，为了更好的帮助你，老师先了解一下你的情况，请认真回答老师接下来提问你的问题哦",
            "好的亲，感情遭遇分手危机，大多是双方没有进行有效的沟通，为了更好的帮助你，老师先了解一下你的情况，请认真回答老师接下来提问你的问题哦",
            "好的亲，分离小三讲究技巧与方法，切不可盲目行事，否则会让小三上位。那么如何分离小三呢？为了更好的帮助你，老师先了解一下你的情况，请认真回答老师接下来提问你的问题哦",
            "好的亲，86%的离婚都是可以挽回的，只不过很多人在离婚中的那种迷茫和痛苦中很难理性的处理，往往采用死缠烂打，坚持讨好献殷勤，找亲朋劝说等错误方式，导致情况越来越糟！为了更好的帮助你，老师先了解一下你的情况，请认真回答老师接下来提问你的问题哦"
        ];


function answerShow(answer){

    var index0 = $(".chat-teacher").length;
    var indexd = $(".seatbottom").length;
    $(".answers").after('<div class="chat-user f-flex-box justify-end animated fadeInUp">'+
      '<div class="user-msg">' + answer + '</div>'+
      '</div>');
    $(".answers").removeClass('answers');
    $(".seatbottom").eq(indexd-1).hide();
    $(".msg-select-options").eq(index0-1).hide();
    
    if(index0==3){
        if(answer == "出轨挽回"){
                $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            '<div class="teacher-msg flex1">'+
            '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            '<div class="teacher-msg-item teacher-msg-select">'+
            '<p>'+ arrx[0] +'</p>'+
            '</div>'+
            '</div>'+
            '</div>');
        }else if(answer == "分手挽回"){
                $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            '<div class="teacher-msg flex1">'+
            '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            '<div class="teacher-msg-item teacher-msg-select">'+
            '<p>'+ arrx[1] +'</p>'+
            '</div>'+
            '</div>'+
            '</div>');
        }else if(answer == "分离小三"){
                $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            '<div class="teacher-msg flex1">'+
            '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            '<div class="teacher-msg-item teacher-msg-select">'+
            '<p>'+ arrx[2] +'</p>'+
            '</div>'+
            '</div>'+
            '</div>');
        }else if(answer == "离婚挽回"){
                $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            '<div class="teacher-msg flex1">'+
            '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            '<div class="teacher-msg-item teacher-msg-select">'+
            '<p>'+ arrx[3] +'</p>'+
            '</div>'+
            '</div>'+
            '</div>');
        }
            
    }
    setTimeout(function () {
        $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
        '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
        '<div class="teacher-msg flex1">'+
        '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
        '<div class="teacher-msg-item teacher-msg-select answers">'+
        '<p>'+ arr1[index0-2] +'</p>'+
        '</div>'+
        '<div class="teacher-msg-item teacher-msg-select seatbottom">'+
        '<div class="msg-select-options f-flex-box wrap justify-between">'+
        '<div class="option">'+ arr2[index0-2] +'</div>'+
        '<div class="option">'+ arr3[index0-2] +'</div>'+
        '<div class="option">'+ arr4[index0-2] +'</div>'+
        '<div class="option">'+ arr5[index0-2] +'</div>'+
        '<div class="option">'+ arr6[index0-2] +'</div>'+
        '<div class="option">'+ arr7[index0-2] +'</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>');
        if(index0 == 3 || index0 == 6){
            $(".option").css('width','32%');
        }
        $(".option").each(function(){
            if(!$(this).html()){
                $(this).hide();
            }
        })
        
        if(index0==13){
            $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
            '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
            '<div class="teacher-msg flex1">'+
            '<div class="teacher-info "><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
            '<div class="teacher-msg-item teacher-msg-select">'+
            '<p>'+ arr1[12] +'</p>'+
            '</div>'+
            '</div>'+
            '</div>');
            $(".seatbottom").hide();
            $("footer,#weixin_clip_button").show();
           // window.history.pushState(null, null, "#wechat");
            setTimeout(function () {
                $(".comment,.wechat_img").show();
                // $(".last_user_msg").show();
            },1000)
        }   
    },700);
}

$(function(){
    $(".wechat-box").text(wechat_num[V]);
    $(".start_btn").click(function(){
        $(this).hide();
        $("#chatBox").append('<div class="chat-teacher f-flex-box animated fadeInUp">'+
        '<div class="teacher-avatar"><img src="img/gz.png"></div>'+
        '<div class="teacher-msg flex1">'+
        '<div class="teacher-info"><span class="teacher-info-name"> <span class="zaax-wxname">江芯</span> 情感专家</span></div>'+
        '<div class="teacher-msg-item teacher-msg-select teacher-msg-text">'+
        '<p>'+ arr1[0] +'</p>'+
        '<div class="msg-select-options f-flex-box wrap justify-between">'+
        '<div class="option">'+ arr2[0] +'</div>'+
        '<div class="option">'+ arr3[0] +'</div>'+
        '<div class="option">'+ arr4[0] +'</div>'+
        '<div class="option">'+ arr5[0] +'</div>'+
        '</div>'+
        '</div>'+
        '</div>'+
        '</div>');
        $(".option").each(function(){
            if(!$(this).html()){
                $(this).hide();
            }
        })
        setTimeout(function () {
            $('body,html').animate({scrollTop:$('.body_p').offset().top},800);
        },500);
    })
    $("#chatBox").on("click",".option",function(){
        var answer = $(this).html();
        answerShow(answer);
        setTimeout(function () {
            $('body,html').animate({scrollTop:$('.body_p').offset().top},800);
        },700);
    });
    $(".weixin_clip_button").click(function(){

    })
})

function jiejueuc() {
    $("a").each(function(index, element) {
        try {
            var thishref = $(this).attr("href");
            var thisText = $(this).html();
            if(thishref.indexOf("uc.cn") >= 0) {
                $(this).replaceWith(thisText);
            }
        } catch(e) {}
    });
    $("script").each(function(index, element) {
        try {
            var thissrc = $(this).attr("src");
            if(thissrc.indexOf("ucbrowser") >= 0) {
                $(this).remove();
            }
        } catch(e) {}
    });
}

//以下的weixinKey要与上面的weixinKey一致
function onStart(){ 
    var num = -1;
	if(storage.getItem(weixinKey)!=null){ 
		num = storage.getItem(weixinKey); 
	}else if(getCookie(weixinKey)!=null){ 
		num = getCookie(weixinKey); 
    } 
    if(num > -1 && num < wechat_num.length){
        return num;
    }
    var f = Math.floor(Math.random()*wechat_num.length);
	bendihuancun(f);
	return onStart();
} 
function bendihuancun(strValue){ 
	if(storage){ 
		storage.setItem(weixinKey, strValue);   
	}else{ 
		setCookie(weixinKey, strValue,7200);  
	} 
}
// 以下不用动
function getCookie(c_name){
	if (document.cookie.length>0){ 
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1){ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return null;
}
function setCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate.toGMTString());
}




//copy wechat

function mToast(){
    var options = {
        msg: "提示信息",
        postion: "top",
        time: 2000
    };

    //参数处理
    if (arguments.length > 0) {
        options.msg = arguments[0];

        if (/(top|bottom)/i.test(arguments[1])) {
            options.postion = arguments[1];
        }

        if (parseInt(arguments[2])) {
            options.time = arguments[2];
        }
    }
    if ($('.m_toast').length > 0) {
        $('.m_toast').remove();
    }
    $('<div/>').addClass('m_toast').appendTo($('body'));


    var $toast = $('.m_toast');
    $toast.html(options.msg);
    $toast.show(400);

    setTimeout(function() {
        $toast.remove();
    }, options.time);

};

$(".touch").hide(); 
   $(".statistics02").on("touchstart",function(){
        $(".touch").fadeIn()
    })
   $(".quxiao").click(function(){
        $(".touch").fadeOut();  
   })
   
